const { cartFormatError } = require("../constant/error.type");
/**添加购物车参数校验,采用闭包形式复用参数校验 */
const cartsValidator = (rules) => {
  return async (ctx, next) => {
    try {
      ctx.verifyParams(rules)
    } catch (error) {
      cartFormatError.result = error
      return ctx.app.emit('error', cartFormatError, ctx)
    }
    await next()
  }
}
module.exports = {
  cartsValidator
}